package com.orhon.smartcampus.modules.notice.fetcher;

import com.orhon.smartcampus.modules.notice.mutation.AddNoticeMutation;
import com.orhon.smartcampus.modules.notice.mutation.DeleteNoticeMutation;
import graphql.schema.idl.RuntimeWiring;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class NoticeFetchersLoader {

    @Autowired
    NoticeFetcher noticeFetcher;

    @Autowired
    NoticesFetcher noticesFetcher;

    @Autowired
    AddNoticeMutation addNoticeMutation;

    @Autowired
    DeleteNoticeMutation deleteNoticeMutation;

    public void LoadFetchers(RuntimeWiring.Builder builder){
        //users -> data
        builder.type("Query" , t->t.dataFetcher("notice" , noticeFetcher));
        builder.type("Query" , t->t.dataFetcher("notices" , noticesFetcher));

        builder.type("Mutation" , t->t.dataFetcher("addNotice" , addNoticeMutation));
        builder.type("Mutation" , t->t.dataFetcher("deleteNotice" , deleteNoticeMutation));
    }
}
